package com.by.common.bean;

import com.by.common.utils.MapUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


public class Page {
    @ApiModelProperty(value = "当前第几页,默认第1页")
    int page = 1;
    @ApiModelProperty(value = "每页记录数,默认10条", required = false)

    int pageSize = 10;

    @ApiModelProperty(value = "企业id",required = true)
    int eid;

    public int getEid() {
        return eid;
    }

    public void setEid(int eid) {
        this.eid = eid;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        if (page == 0)
            this.page = 1;
        else
            this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if (pageSize == 0)
            this.pageSize = 10;
        else
            this.pageSize = pageSize;
    }

    /**
     * 将javabean转换为map
     *
     * @return
     */
    public Map toMap() {
        //先转换父类
        Map parentMap = MapUtils.convertToMap(getClass().getSuperclass(), this);
        //获取当前类
        Map childMap = MapUtils.convertToMap(getClass(), this);
        parentMap.putAll(childMap);
        return parentMap;
    }


}
